﻿using System.Collections.Generic;
using System.IO;
using System.Reflection;
using msilgc.cbuilder;

namespace msilgc.driver.cuda
{
    public class CudaCompilerHelper {

        public void CreateCudaImplementation(
            DirectoryInfo dllPath, IEnumerable<MethodInfo> methodsToTranslate, out string compilerMessage, out string kernelCode, bool debug) {
                new CudaCodeGenerator().GenerateNativeLibrary(
                    dllPath, new Compiler().TranslateMethods(methodsToTranslate), 
                    out compilerMessage, out kernelCode, debug);
        }

        public void CreateCudaImplementation(
            DirectoryInfo dllPath, MethodInfo methodToTranslate, out string compilerMessage, out string kernelCode, bool debug)
        {
            new CudaCodeGenerator().GenerateNativeLibrary(dllPath, new Compiler().TranslateMethod(methodToTranslate), out compilerMessage, out kernelCode, debug);
        }

        public string ShowCDriverCode(MethodInfo method)
        {
            return new CudaCodeGenerator().WriteCode(new Compiler().TranslateMethod(method), true);
        }

        public string DisassembleMethod(MethodInfo method)
        {
            return new Compiler().DissassembleMethod(method);
        }
    }
}
